package com.cn.project.service.impl;

import com.cn.common.pojo.ItemModel;
import com.cn.common.pojo.ResultModel;
import com.cn.project.mapper.ItemDao;
import com.cn.project.service.ItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class ItemServiceImpl implements ItemService {
    @Autowired
    ItemDao itemDao;

    @Override
    public ResultModel item() {
        return ResultModel.Data(itemDao.item());
    }

    @Override
    public ResultModel delete(int id) {
        return ResultModel.getResultModelByCount(itemDao.delete(id));
    }

    @Override
    public ResultModel update(ItemModel itemModel) {
        return ResultModel.getResultModelByCount(itemDao.update(itemModel));
    }

    @Override
    public ResultModel insert(ItemModel itemModel) {
        return ResultModel.getResultModelByCount(itemDao.insert(itemModel));
    }

    @Override
    public ResultModel enable(int id) {
        return ResultModel.getResultModelByCount(itemDao.enable(id));
    }

    @Override
    public ResultModel findById(int id) {
        return ResultModel.getResultModelByAll(itemDao.findById(id),1);
    }

    @Override
    public ResultModel limit(ItemModel itemModel) {
        return ResultModel.getResultModel("",0,1,itemDao.limit(itemModel));
    }
}
